WorkerScript.onMessage = function(message) {
    doLoadSpot(message);
}

function doLoadSpot(message) {
    var xhr = new XMLHttpRequest;
    var url = "https://production-2.sogeoapi.com/api/poi/" + message.spotId + "?oauth_token=" + message.token + "&stats=true";
    xhr.open("GET", url);
    xhr.onreadystatechange = function() {
        if (xhr.readyState == XMLHttpRequest.DONE) {
            var response = JSON.parse(xhr.responseText);
            var fullAddress =  response.data.poi.street + ", " + response.data.poi.city + ", " + response.data.poi.country
            WorkerScript.sendMessage({ 'spotAddress': fullAddress });
        }
    }
    xhr.send();
}
